﻿using SilverlightClientApp.WFServiceReference;

namespace SilverlightClientApp.Manager
{
    public class CustomerManager
    {
        public string CustomerName
        {
            get; private set;
        }

        private readonly CustomerServiceClient _client;

        internal CustomerManager()
        {
            _client = new CustomerServiceClient();
        }

        public void LoadCustomer(int value)
        {
            _client.GetNameCompleted += CustomerManagerGetDataCompleted;
            _client.GetNameAsync(value);
        }

        protected void CustomerManagerGetDataCompleted(object sender, GetNameCompletedEventArgs args)
        {
            ((CustomerServiceClient)sender).CloseAsync();
            CustomerName = args.Result;
        }
    }
}
